<small>
    <span class="dropdown" style="display:inline-block">
        <a id="" class="dropdown-toggle btn btn-white  waves-effect" data-toggle="dropdown" href="javascript:void(0)">
            <stub>自动更新频率：</stub><span class="caret"> {{ $autoRefresh }} 秒</span>
        </a>
        <ul class="dropdown-menu" style="left: 0px; right: inherit;">
            <li class="dropdown-item">
                <a href="javascript:void(0)" onclick="setAutoRefresh(3)">3 秒</a>
            </li>
            <li class="dropdown-item">
                <a href="javascript:void(0)" onclick="setAutoRefresh(5)">5 秒</a>
            </li>
            <li class="dropdown-item">
                <a href="javascript:void(0)" onclick="setAutoRefresh(10)">10 秒</a>
            </li>
            <li class="dropdown-item">
                <a href="javascript:void(0)" onclick="setAutoRefresh(30)">30 秒</a>
            </li>
            <li class="dropdown-item">
                <a href="javascript:void(0)" onclick="setAutoRefresh(60)">60 秒</a>
            </li>
        </ul>
    </span>
</small>
<script type="text/javascript">
    function setAutoRefresh(seconds){
        console.log(seconds)
        let url = "{{ URL::asset('admin/setAutoRefresh') }}";
        let data = {
            _token: '{{ csrf_token() }}',
            value: seconds,
            key: '{{ $key }}',
        }
        $.ajax({
            type : "POST",
            url : url,
            data : data,
            success : function(result) {
                console.log(result)
                if (result.code == 1) {
                    location.reload();
                } else {
                    console.log(result.msg)
                }
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                layer.close(e);
                console.log(e.status);
                console.log(e.responseText);
            }
        });
    }
</script>